/**
 * Bookshelf路由模块
 * routes\bookshelves.js
 */

var express = require("express");
var router = express.Router();

const bookshelf = require("../controller/bookshelf");
const auth = require("../controller/auth");

//定义路由

//守卫路由：所有路由必须执行权限控制的判断
router.all("*", auth.isLogin);

router.get("/count", bookshelf.getCount);

router.get('/', bookshelf.findAll);

router.get('/:id', bookshelf.find);

router.post('/', bookshelf.add);

router.put('/:id', bookshelf.update);

router.delete('/:id', bookshelf.remove);

router.patch("/read-status/:id", bookshelf.updateReadStatus);

router.patch("/ranking/:id", bookshelf.updateRanking);

router.get("/book/:book_id", bookshelf.findByBookId);

router.get("/average-ranking/:book_id", bookshelf.avgRankingByBookId);


module.exports = router;